//
//  SLGenderView.m
//  BXlive
//
//  Created by sweetloser on 2020/8/27.
//  Copyright © 2020 cat. All rights reserved.
//

#import "SLSettingGenderView.h"
#import <MJRefresh/MJRefresh.h>
#import <SLDeveloperTools/SLDeveloperTools.h>
#import <Masonry/Masonry.h>

@implementation SLSettingGenderView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        [self setupUI];
    }
    return self;
}

-(void)setupUI{
    self.contentView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, __ScaleWidth(281), __ScaleWidth(165))];
    [self addSubview:self.contentView];
    
    self.contentView.center = CGPointMake(self.mj_w/2, self.mj_h/2);
    self.contentView.backgroundColor = sl_BGColors;
    self.contentView.layer.masksToBounds = YES;
    self.contentView.layer.cornerRadius = 12;
    
    
    UILabel *titleL = [UILabel createLabelWithFrame:CGRectZero BackgroundColor:SLClearColor Text:NSLocalizedString(@"选择性别", nil) Font:SLBFont(16) TextColor:sl_textColors];
    titleL.textAlignment = NSTextAlignmentCenter;
    [self.contentView addSubview:titleL];
    
    [titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.top.mas_equalTo(__ScaleWidth(30));
        make.height.mas_equalTo(__ScaleWidth(22));
    }];
    
    UIButton *nanBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:nanBtn];
    [nanBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(__ScaleWidth(50));
        make.height.mas_equalTo(__ScaleWidth(70));
        make.top.equalTo(titleL.mas_bottom).offset(__ScaleWidth(20));
        make.left.mas_equalTo(__ScaleWidth(55));
    }];
    [nanBtn setImage:CImage(@"setting_gender_man") forState:BtnNormal];
    [nanBtn setImage:CImage(@"setting_gender_man") forState:UIControlStateHighlighted];
    
    [nanBtn setImageEdgeInsets:UIEdgeInsetsMake(__ScaleWidth(-15), 0, __ScaleWidth(15), 0)];
    
    UILabel *nanLabel = [UILabel createLabelWithFrame:CGRectZero BackgroundColor:SLClearColor Text:NSLocalizedString(@"男", nil) Font:SLPFFont(14) TextColor:sl_textColors];
    nanLabel.textAlignment = NSTextAlignmentCenter;
    [nanBtn addSubview:nanLabel];
    [nanLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(__ScaleWidth(20));
        make.bottom.mas_equalTo(0);
    }];
    
    
    UIButton *nvBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.contentView addSubview:nvBtn]; 
    [nvBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(__ScaleWidth(50));
        make.height.mas_equalTo(__ScaleWidth(70));
        make.top.equalTo(titleL.mas_bottom).offset(__ScaleWidth(20));
        make.right.mas_equalTo(__ScaleWidth(-55));
    }];
    
    [nvBtn setImage:CImage(@"setting_gender_woman") forState:BtnNormal];
    [nvBtn setImage:CImage(@"setting_gender_woman") forState:UIControlStateHighlighted];
    
    [nvBtn setImageEdgeInsets:UIEdgeInsetsMake(__ScaleWidth(-15), 0, __ScaleWidth(15), 0)];
    
    UILabel *nvLabel = [UILabel createLabelWithFrame:CGRectZero BackgroundColor:SLClearColor Text:NSLocalizedString(@"女", nil) Font:SLPFFont(14) TextColor:sl_textColors];
    nvLabel.textAlignment = NSTextAlignmentCenter;
    [nvBtn addSubview:nvLabel];
    [nvLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.mas_equalTo(0);
        make.height.mas_equalTo(__ScaleWidth(20));
        make.bottom.mas_equalTo(0);
    }];
    
    [nanBtn addTarget:self action:@selector(nanBtnAction) forControlEvents:BtnTouchUpInside];
    [nvBtn addTarget:self action:@selector(nvBtnAction) forControlEvents:BtnTouchUpInside];
    
}

-(void)nanBtnAction{
    NSLog(NSLocalizedString(@"男", nil));
    
    if (self.ComplateBlock) {
        self.ComplateBlock(@"1");
    }
    
    [self hiddenView];
}
-(void)nvBtnAction{
    NSLog(NSLocalizedString(@"女", nil));
    
    if (self.ComplateBlock) {
        self.ComplateBlock(@"2");
    }
    
    [self hiddenView];
}



@end
